package org.example.studentsdemo.teachers.controller;


import org.example.studentsdemo.teachers.DTO.addStudentsToTeacherDTO;
import org.example.studentsdemo.teachers.entity.teachers;
import org.example.studentsdemo.teachers.service.teachersService;
import org.example.studentsdemo.utils.HttpResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/teachers")
public class teachersController {

      @Autowired
      private teachersService teacherService;


      @GetMapping("/getTeacherList")
    public ResponseEntity<HttpResult<List<teachers>>> getTeacherList() {
        return  teacherService.getTeacherList();
      }
    @GetMapping("/getTeacherById")
    public ResponseEntity<HttpResult<teachers>> getTeacherById(@RequestParam Long id) {
        return  teacherService.getTeacherById(id);
    }
    @PostMapping("/addTeacher")
    public ResponseEntity<HttpResult<teachers>> addTeacher(@RequestBody teachers teacher) {
        return  teacherService.addTeacher(teacher);
    }
    @PostMapping("/updateTeacher")
    public ResponseEntity<HttpResult<teachers>> updateTeacher(@RequestBody teachers teacher) {
        return  teacherService.updateTeacher(teacher);
    }
    @PostMapping("/deleteTeacher")
    public ResponseEntity<HttpResult<Boolean>> deleteTeacher(@RequestBody Long id) {
        return  teacherService.deleteTeacher(id);
    }
    @PostMapping("/addStudentsToTeacher")
    public ResponseEntity<HttpResult<Boolean>> addStudentsToTeacher(@RequestBody addStudentsToTeacherDTO addStudentsToTeacherDTO) {
        return  teacherService.addStudentsToTeacherDTO(addStudentsToTeacherDTO);
    }

}
